package com.buanalintas.sandals.pos.opnamedetail;

import com.buanalintas.bynga.Action;
import com.buanalintas.bynga.Controller;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.sandals.pos.entities.PosMasterSize;
import com.buanalintas.sandals.pos.entities.PosTransactionOpnameDetail;
import com.buanalintas.sandals.pos.opnamedetail.AddSize;

public class OpnameDetail extends Page {

    private Field opnameDetailId;
    private Field opnameDetailOpnameId;
    private Field opnameDetailItemId;
    private Field opnameDetailStatusId;
    private Field opnameDetailSizeId;
    private Field opnameDetailSize;
    private Field opnameDetailOldValue;
    private Field opnameDetailNewValue;
    private Field opnameDetailDescription;

    public OpnameDetail() {
        super();
        setTheClass(PosTransactionOpnameDetail.class);

        opnameDetailId = new Field();
        opnameDetailId.setName("opnameDetailId");
        opnameDetailId.setCaption("id");
        opnameDetailId.setListProperties("");
        opnameDetailId.setInputProperties("");
        getFields().add(opnameDetailId);

        opnameDetailOpnameId = new Field();
        opnameDetailOpnameId.setName("opnameDetailOpnameId");
        opnameDetailOpnameId.setCaption("opname");
        opnameDetailOpnameId.setListProperties("");
        opnameDetailOpnameId.setInputProperties("");
        getFields().add(opnameDetailOpnameId);

        opnameDetailItemId = new Field();
        opnameDetailItemId.setName("opnameDetailItemId");
        opnameDetailItemId.setCaption("item");
        opnameDetailItemId.setListProperties(" align=\"left\" width=\"30%\" nowrap");
        opnameDetailItemId.setInputProperties("");
        opnameDetailItemId.setRequired(true);
        opnameDetailItemId.getSelectorColumns().add(new String[]{"itemCode", " Code", "width=\"5%\" nowrap"});
        opnameDetailItemId.getSelectorColumns().add(new String[]{"itemModel", " Model", "width=\"90%\""});
        opnameDetailItemId.setSelectorOrder("t.itemCode");
        getFields().add(opnameDetailItemId);

        opnameDetailStatusId = new Field();
        opnameDetailStatusId.setName("opnameDetailStatusId");
        opnameDetailStatusId.setCaption("status");
        opnameDetailStatusId.setListProperties(" align=\"left\" width=\"30%\" nowrap");
        opnameDetailStatusId.setInputProperties(" ");
        opnameDetailStatusId.setInputType(Field.INPUT_COMBO_BOX);
        opnameDetailStatusId.setRequired(true);
        getFields().add(opnameDetailStatusId);
        
        opnameDetailSize = new Field();
        opnameDetailSize.setName("opnameDetailSize");
        opnameDetailSize.setCaption("size");
        opnameDetailSize.setListProperties(" align=\"left\" width=\"30%\" nowrap");
        opnameDetailSize.setEntityRelation(PosMasterSize.class);
        opnameDetailSize.setInputType(Field.INPUT_CHECK_BOX);
        opnameDetailSize.setRequired(true);
        getFields().add(opnameDetailSize);

        opnameDetailSizeId = new Field();
        opnameDetailSizeId.setName("opnameDetailSizeId");
        opnameDetailSizeId.setCaption("size");
        opnameDetailSizeId.setListProperties(" align=\"left\" width=\"30%\" nowrap");
//        returShopDetailSizeId.setEntityRelation(PosMasterSize.class);
        opnameDetailSizeId.setRequired(true);
        getFields().add(opnameDetailSizeId);

        opnameDetailOldValue = new Field();
        opnameDetailOldValue.setName("opnameDetailOldValue");
        opnameDetailOldValue.setCaption("old value");
        opnameDetailOldValue.setListProperties(" align=\"right\" width=\"10%\" nowrap");
        opnameDetailOldValue.setInputProperties(" size=\"10\"");
        getFields().add(opnameDetailOldValue);

        opnameDetailNewValue = new Field();
        opnameDetailNewValue.setName("opnameDetailNewValue");
        opnameDetailNewValue.setCaption("new value");
        opnameDetailNewValue.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        opnameDetailNewValue.setInputProperties(" size=\"10\"");
        opnameDetailNewValue.setRequired(true);
        getFields().add(opnameDetailNewValue);

        opnameDetailDescription = new Field();
        opnameDetailDescription.setName("opnameDetailDescription");
        opnameDetailDescription.setCaption("description");
        opnameDetailDescription.setListProperties(" width=\"50%\"");
        opnameDetailDescription.setInputProperties(" cols=\"50\" rows=\"5\"");
        opnameDetailDescription.setInputType(Field.INPUT_TEXT_AREA);
        opnameDetailDescription.setInputCase(Field.CASE_UPPER);
        getFields().add(opnameDetailDescription);
        
        fillFields();

        getFieldsAdd().clear();
        getFieldsAdd().add(opnameDetailItemId);
        getFieldsAdd().add(opnameDetailSize);
        getFieldsAdd().add(opnameDetailStatusId);
        getFieldsAdd().add(opnameDetailNewValue);
        getFieldsAdd().add(opnameDetailDescription);

        getFieldsEdit().clear();
        getFieldsEdit().add(opnameDetailItemId);
        getFieldsEdit().add(opnameDetailSizeId);
        getFieldsEdit().add(opnameDetailStatusId);
        getFieldsEdit().add(opnameDetailNewValue);
        getFieldsEdit().add(opnameDetailDescription);

        getFieldsList().clear();
        getFieldsList().add(opnameDetailItemId);
        getFieldsList().add(opnameDetailSizeId);
        getFieldsList().add(opnameDetailStatusId);
        getFieldsList().add(opnameDetailNewValue);
        getFieldsList().add(opnameDetailDescription);

        getActions().add(Action.TRANS_DETAIL_LIST);
        getActions().add(Action.TRANS_DETAIL_ADD);
        getActions().add(Action.TRANS_DETAIL_EDIT);

        setController(new Controller(this));
    }
     @Override
    public StringBuffer process() {
        if (getAction().equals(Action.TRANS_DETAIL_ADD)) {
            return AddSize.process(this);
        }
//        if (getAction().equals(Action.TRANS_DETAIL_LIST)) {
//            return ListTransaction.process(this);
//        }
        return super.process();
    }
}
